package day_2022_9_to_12.Day;

import java.util.Deque;
import java.util.LinkedList;

/**
 * @author haomin
 * @date 2022/10/21 11:03
 **/
public class Day49_1_Num901_StockSpanner {
    class StockSpanner {
        Deque<int[]> stack;
        public StockSpanner() {
            stack = new LinkedList<>();
            stack.push(new int[]{0, Integer.MAX_VALUE});
        }
        int i = 0;
        public int next(int price) {
            i++;
            while(stack.peek()[1] <= price) stack.pop();
            int ans = i - stack.peek()[0];
            stack.push(new int[]{i, price});
            return ans;
        }
    }
}